package com.ruoyi.otc.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.otc.domain.BusinessTopicLog;
import com.ruoyi.otc.service.IBusinessTopicLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业评测记录Controller
 * 
 * @author gjp
 * @date 2023-10-24
 */
@Controller
@RequestMapping("/otc/businessTopicLog")
public class BusinessTopicLogController extends BaseController
{
    private String prefix = "otc/businessTopicLog";

    @Autowired
    private IBusinessTopicLogService businessTopicLogService;

    @RequiresPermissions("otc:businessTopicLog:view")
    @GetMapping()
    public String businessTopicLog()
    {
        return prefix + "/businessTopicLog";
    }

    /**
     * 查询企业评测记录列表
     */
    @RequiresPermissions("otc:businessTopicLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BusinessTopicLog businessTopicLog)
    {
        startPage();
        List<BusinessTopicLog> list = businessTopicLogService.selectBusinessTopicLogList(businessTopicLog);
        return getDataTable(list);
    }

    /**
     * 导出企业评测记录列表
     */
    @RequiresPermissions("otc:businessTopicLog:export")
    @Log(title = "企业评测记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BusinessTopicLog businessTopicLog)
    {
        List<BusinessTopicLog> list = businessTopicLogService.selectBusinessTopicLogList(businessTopicLog);
        ExcelUtil<BusinessTopicLog> util = new ExcelUtil<BusinessTopicLog>(BusinessTopicLog.class);
        return util.exportExcel(list, "企业评测记录数据");
    }

    /**
     * 新增企业评测记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存企业评测记录
     */
    @RequiresPermissions("otc:businessTopicLog:add")
    @Log(title = "企业评测记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BusinessTopicLog businessTopicLog)
    {
        return toAjax(businessTopicLogService.insertBusinessTopicLog(businessTopicLog));
    }

    /**
     * 修改企业评测记录
     */
    @RequiresPermissions("otc:businessTopicLog:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BusinessTopicLog businessTopicLog = businessTopicLogService.selectBusinessTopicLogById(id);
        mmap.put("businessTopicLog", businessTopicLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存企业评测记录
     */
    @RequiresPermissions("otc:businessTopicLog:edit")
    @Log(title = "企业评测记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BusinessTopicLog businessTopicLog)
    {
        return toAjax(businessTopicLogService.updateBusinessTopicLog(businessTopicLog));
    }

    /**
     * 删除企业评测记录
     */
    @RequiresPermissions("otc:businessTopicLog:remove")
    @Log(title = "企业评测记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(businessTopicLogService.deleteBusinessTopicLogByIds(ids));
    }
}
